package com.cskaoyan.controller;

import com.cskaoyan.bean.AdminListRespVo;
import com.cskaoyan.bean.StorageVO;
import com.cskaoyan.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @USER: cuiweiguo#
 * @DATE: 2022/5/9
 * @TIME: 10:04
 * @PROJECT_NAME: mallproject2
 */
@RestController
@RequestMapping("wx/storage")
public class WxStorageController {
    @Autowired
    StorageService storageService;

    @RequestMapping("upload")
    public AdminListRespVo<StorageVO> storage(MultipartFile file) throws IOException {
        //POST http://182.92.235.201:8083/admin/storage/create HTTP/1.1
        //文件上传
        //transferTo → 参数 MultipartFile转换为一个什么样的file

        //将文件信息保存至数据库
        StorageVO storageVO = storageService.storage(file);
        return AdminListRespVo.listOk(storageVO);
    }
}
